from PIL import ImageGrab
from lib.controller.mouse_controller import MouseController

import time


class ImageTools:

    def __init__(self):
        self.im = None

    def grab_image(self):
        ms = MouseController()
        print('请把鼠标放到第一个坐标')
        time.sleep(5)
        x, y = ms.controller.position
        print('请把鼠标放到第二个坐标')
        time.sleep(5)
        n, m = ms.controller.position
        boxx = (x, y, n, m)
        self.im = ImageGrab.grab(boxx)
        self.im.show()

#
# if __name__ == '__main__':
#     it = ImageTools()
#     it.grab_image()